<?php

namespace App\Http\Controllers\Home;

use App\Models\Article;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ArticleController extends Controller
{
    public function index()
    {
        $data = Article::latest()->with(['tags','category'])->paginate(12);
        return view('home.news_list',compact('data'));
    }

    public function show($id)
    {
        $data = Article::with(['tags'])->findOrFail($id);
        $data->increment('click',1);
        $new = Article::latest()->take(5)->get();
        return view('home.article',compact('data','new'));
    }
}
